
package org.jdcenter.jndi.context;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;

import org.jdcenter.jndi.context.local.LocalProxyContext;
import org.jdcenter.jndi.context.remote.RemoteProxyContext;

/**
 * @author miao
 */
public class NamingContextFactory implements InitialContextFactory{


    public Context getInitialContext(Hashtable<?,?> env) throws NamingException {
        String address = (String)env.get(Context.PROVIDER_URL);
    	if(address == null){
    		return LocalProxyContext.getContext();
    	}else{
    		return RemoteProxyContext.getContext(address);
    	}
    }
    
    public static void main(String[] args) {

    }
}
